package org.mspring.mlog.dao.impl;

import org.mspring.mlog.dao.CommentEntityDao;
import org.mspring.mlog.entity.CommentEntity;
import org.mspring.mlog.common.constants.CommentStatus;
import org.mspring.nbee.db.dao.impl.BaseDao;
import org.mspring.nbee.db.dao.sql.Sql;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author Gao Youbo
 * @since 2015-01-03 14:38:20
 */
@Repository
public class CommentEntityDaoImpl extends BaseDao<CommentEntity> implements CommentEntityDao {

    @Override
    public List<CommentEntity> listByArticle(long articleId) {
        Sql sql = new Sql("select * from t_comment where article_id = ? and status = ?", articleId, CommentStatus.APPROVED);
        return listBySql(sql);
    }

    @Override
    public CommentEntity findByDuoshuoCommentId(long duoshuoCommentId) {
        Sql sql = new Sql("select * from t_comment where duoshuo_comment_id = ?", duoshuoCommentId);
        return findBySql(sql);
    }
}
